// import proFetch from "../../../../../public/functions/project-fetch";
import {hrAjax as ajax} from 'src/hrpub/common/utils/utils';

import updateButtonStatus from "./updateButtonStatus";
import {toast} from 'nc-lightapp-front';
import getOneAgreementInfo from "./getOneAgreementInfo";

export default function saveAgreementData(callback) {
    const {orgVal, agreementType, json} = this.state;
    const agreementData = this.props.form.getAllFormValue(agreementType + 'Card', true);

    return ajax({
        url: '/nccloud/hrcm/agreement/ReleaseSaveAction.do',
        body: {
            agreementData: agreementData,
            pk_org: orgVal && orgVal.refpk ? orgVal.refpk : null,
            nodecode: '60110507',
            agreementType: agreementType
        },
    }).then((res) => {
        if (res.success) {
            this.setState({
                isEdit: false
            });
            this.props.editTable.setStatus(this.state.agreementType + 'Card', 'browse');
            getOneAgreementInfo.call(this)
            updateButtonStatus.call(this, this.state.orgVal, this.state.agreementType, false);
            toast({color: 'success', content: json['cm6011-000005']});
            callback && callback();
        }
    });

}
